/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package grsu.epam.airline.action;

import grsu.epam.airline.service.AirportService;
import grsu.epam.airline.service.EmployeeService;
import grsu.epam.airline.service.FlightCrewService;
import grsu.epam.airline.service.FlightService;
import grsu.epam.airline.service.PlaneService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import org.apache.struts.actions.DispatchAction;

public class LinkAction extends DispatchAction {

	String target;

	public ActionForward employees(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		EmployeeService employeeService = new EmployeeService();
		request.setAttribute("employees", employeeService.getAllEmployee());
		target = ForwardActionTo.EMPLOYEES;
		return mapping.findForward(target);
	}

	public ActionForward flights(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		FlightService flightService = new FlightService();
		request.setAttribute("flights", flightService.getAllFlight());
		target = ForwardActionTo.FLIGHTS;
		return mapping.findForward(target);
	}

	public ActionForward flightcrews(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		FlightCrewService flightCrewService = new FlightCrewService();
		request.setAttribute("flightCrews",
				flightCrewService.getAllFlightCrew());
		target = ForwardActionTo.FLIGHTCREW;
		return mapping.findForward(target);
	}

	public ActionForward planes(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		PlaneService planeService = new PlaneService();
		request.setAttribute("planes", planeService.getAllPlane());
		target = ForwardActionTo.PLANES;
		return mapping.findForward(target);
	}

	public ActionForward airports(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		AirportService airportService = new AirportService();
		request.setAttribute("airports", airportService.getAllAirport());
		target = ForwardActionTo.AIRPORTS;
		return mapping.findForward(target);
	}

}